package pchi.pchicamera.adapters;

import java.util.ArrayList;

import pchi.pchicamera.R;
import pchi.pchicamera.data.EffectHolder;
import pchi.pchicamera.data.MyItemEffectHolder;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class EffectAdapter extends BaseAdapter {

	private Context context;
	private ArrayList<MyItemEffectHolder> mEffect;
	private LayoutInflater inflater;

	public EffectAdapter(Context context, ArrayList<MyItemEffectHolder> mEffect) {
		super();
		this.context = context;
		this.mEffect = mEffect;
		inflater = LayoutInflater.from(this.context);
	}

	@Override
	public int getCount() {
		return mEffect.size();
	}

	@Override
	public Object getItem(int position) {
		return null;
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View item, ViewGroup parent) {

		EffectHolder effectHolder = new EffectHolder();
		item = inflater.inflate(R.layout.effect_item, null);

		TextView txt = (TextView) item.findViewById(R.id.effect_item_label);
		txt.setText(mEffect.get(position).getName());

		ImageView icon = (ImageView) item.findViewById(R.id.effect_item_image);
		icon.setImageResource(mEffect.get(position).getIcon());
		item.setTag(effectHolder);
		return item;
	}
}
